home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
vol_100
/
161_01
/
tst_sort.c
< prev
next >
Wrap
C/C++ Source or Header
|
1985-08-28
|
384b
|
22 lines
/* tst_sort - returns YES if array a is sorted
* specialized "short" version
*/
#include "local.h"
bool tst_sort(a, n)
short a[];
index_t n;
{
index_t i;
if (n <= 0)
return (NO);
for (i = 1; i < n; ++i)
{
/* a[0:i-1] => sorted */
if (a[i] < a[i-1]) /* compare adjacent elements */
return (NO);
}
/* a[0:n-1] => sorted */
return (YES);
}